import pyautogui
import time
import commonly
import os.path

from _log import _log
pyautogui.moveTo(x=0, y=0, duration=0.5, tween=pyautogui.linear)
pyautogui.FAILSAFE = False
application = "控制面板"
_log = _log(application)
logfile = _log.return_logfile()
logger = _log.return_logger()


commonly = commonly.Commonly(application,logfile)
logger.info("*"*20+"当前测试程序："+application+"*"*20)
os.popen("ukui-control-center")
time.sleep(3)
####################################################################################################################
# 系统主页面#
def system_main():
    commonly.test('Pictures/ukui-control-center/主页面.png',"主页面",move=False)
    commonly.test('Pictures/ukui-control-center/系统.png',"系统")
    pyautogui.moveTo(x=0, y=0, duration=0.5, tween=pyautogui.linear)
    commonly.test('Pictures/ukui-control-center/系统主页面.png',"系统主页面",move=False)
    commonly.test('Pictures/ukui-control-center/系统主页面-2.png',"系统主页面-2")
    pyautogui.scroll(-20)
    commonly.test('Pictures/ukui-control-center/夜间模式开关.png',"夜间模式开关")
    pyautogui.scroll(-20)
    pyautogui.moveTo(x=0, y=0, duration=0.5, tween=pyautogui.linear)
    commonly.test('Pictures/ukui-control-center/夜间模式主页面.png',"夜间模式主页面",click=False)
    commonly.test('Pictures/ukui-control-center/触摸屏.png',"触摸屏")
    commonly.test('Pictures/ukui-control-center/默认应用.png',"默认应用")
    commonly.test('Pictures/ukui-control-center/电源.png',"电源")
    commonly.test('Pictures/ukui-control-center/电源主页面.png',"电源主页面",click=False)
    commonly.test('Pictures/ukui-control-center/开机启动.png',"开机启动")
####################################################################################################################
#设备主页面#
def cache():#强无敌多群
    commonly.test('Pictures/ukui-control-center/设备.png',"设备")
    commonly.test('Pictures/ukui-control-center/设备主页面.png',"设备主页",click=False)
    commonly.test('Pictures/ukui-control-center/添加打印机和扫描仪.png',"添加打印机和扫描仪")
    time.sleep(2)
    commonly.test('Pictures/ukui-control-center/添加打印机主页面.png',"添加打印机主页面",click=False)
    time.sleep(1)
    pyautogui.click()
    time.sleep(1)
    pyautogui.hotkey("Alt","F4")
    commonly.test('Pictures/ukui-control-center/投屏.png',"投屏")
    commonly.test('Pictures/ukui-control-center/鼠标.png',"鼠标")
    commonly.test('Pictures/ukui-control-center/鼠标主页面.png',"鼠标主页面",click=False)
    commonly.test('Pictures/ukui-control-center/触摸板.png',"触摸板")
    commonly.test('Pictures/ukui-control-center/键盘.png',"键盘")
    commonly.test('Pictures/ukui-control-center/键盘主页面.png',"键盘主页面",click=False)
    commonly.test('Pictures/ukui-control-center/输入法设置.png',"输入法设置")
    commonly.test('Pictures/ukui-control-center/输入法主页面.png',"输入法主页面",click=False)
    pyautogui.hotkey("Alt","F4")
    commonly.test('Pictures/ukui-control-center/快捷键.png',"快捷键")
    commonly.test('Pictures/ukui-control-center/快捷键主页面.png',"快捷键主页面",click=False)
    commonly.test('Pictures/ukui-control-center/声音.png',"声音")
    commonly.test('Pictures/ukui-control-center/声音主页面.png',"声音主页面")
    pyautogui.scroll(-200)
    commonly.test('Pictures/ukui-control-center/系统音效.png',"系统音效",click=False)
####################################################################################################################
#个性化#
def gexinghua():
    commonly.test('Pictures/ukui-control-center/个性化.png',"个性化")
    commonly.test('Pictures/ukui-control-center/个性化主页面.png',"个性化主页面",click=False)
    commonly.test('Pictures/ukui-control-center/主题.png',"主题")
    commonly.test('Pictures/ukui-control-center/深色模式.png',"深色模式")
    commonly.test('Pictures/ukui-control-center/系统默认.png',"系统默认")
    commonly.test('Pictures/ukui-control-center/系统默认.png',"深色模式")
    commonly.test('Pictures/ukui-control-center/经典光标.png',"经典光标")
    commonly.test('Pictures/ukui-control-center/时尚光标.png',"时尚光标")
    pyautogui.scroll(-200)
    commonly.test('Pictures/ukui-control-center/个性化恢复默认设置.png',"恢复默认设置")
    commonly.test('Pictures/ukui-control-center/锁屏.png',"锁屏")
    commonly.test('Pictures/ukui-control-center/锁屏主页面.png',"锁屏主页面",click=False)
    commonly.test('Pictures/ukui-control-center/字体.png',"字体")
    commonly.test('Pictures/ukui-control-center/个性化恢复默认设置.png',"恢复默认设置",click=False)
    commonly.test('Pictures/ukui-control-center/屏保.png',"屏保")
    time.sleep(2)
    commonly.test('Pictures/ukui-control-center/屏保主页面.png',"屏保主页面")
    commonly.test('Pictures/ukui-control-center/桌面.png',"桌面")
####################################################################################################################
#网络#
def network():
    commonly.test('Pictures/ukui-control-center/网络.png',"网络")
    commonly.test('Pictures/ukui-control-center/网络主页面.png',"网络主页面",click=False)
    commonly.test('Pictures/ukui-control-center/VPN.png',"VPN")
    commonly.test('Pictures/ukui-control-center/添加VPN.png',"添加vpn")
    commonly.test('Pictures/ukui-control-center/添加VPN主页面.png',"添加vpn主页面",click=False)
    pyautogui.press("Esc")
    commonly.test('Pictures/ukui-control-center/代理.png',"代理")
    commonly.test('Pictures/ukui-control-center/代理主页.png',"代理主页面")
    commonly.test('Pictures/ukui-control-center/桌面共享.png',"桌面共享")
    commonly.test('Pictures/ukui-control-center/打开桌面共享.png',"打开桌面共享")

    commonly.test('Pictures/ukui-control-center/桌面共享主页面.png',"桌面共享主页面")




####################################################################################################################
#账户#
def account():
    commonly.test('Pictures/ukui-control-center/账户.png',"账户")
    commonly.test('Pictures/ukui-control-center/账户详情页.png',"账户详情页",click=False)
    commonly.test('Pictures/ukui-control-center/添加新用户.png',"添加新用户")
    commonly.test('Pictures/ukui-control-center/添加新用户详情页.png',"添加新用户详情页",click=False)
    pyautogui.typewrite(message="kylin2",interval=0.2)
    commonly.test('Pictures/ukui-control-center/输入密码框.png',"输入密码框")
    time.sleep(0.5)
    pyautogui.typewrite(message="kk123123",interval=0.2)
    time.sleep(0.5)
    commonly.test('Pictures/ukui-control-center/确认密码框.png',"确认密码框")
    time.sleep(0.5)
    pyautogui.typewrite(message="kk123123",interval=0.2)
    pyautogui.press("Enter")
    time.sleep(2)
    pyautogui.typewrite(message="kk123123",interval=0.2)
    time.sleep(0.5)
    pyautogui.press("Enter")
    time.sleep(2)
    commonly.test('Pictures/ukui-control-center/云账户.png',"云账户")
####################################################################################################################
#时间语言#
def language():
    commonly.test('Pictures/ukui-control-center/时间语言.png',"时间语言")
    commonly.test('Pictures/ukui-control-center/时间语言主页面.png',"时间语言主页面")
    commonly.test('Pictures/ukui-control-center/添加时区.png',"添加时区")
    commonly.test('Pictures/ukui-control-center/时区-确定.png',"添加时区成功")
    commonly.test('Pictures/ukui-control-center/添加时区.png',"添加时区")
    pyautogui.press("Esc")
    commonly.test('Pictures/ukui-control-center/添加时区.png',"添加时区")
    pyautogui.press("Esc")
    commonly.test('Pictures/ukui-control-center/区域语言.png',"区域语言")

####################################################################################################################
#安全体检#
def safe():
    commonly.test('Pictures/ukui-control-center/安全与更新.png',"安全与更新")
    commonly.test('Pictures/ukui-control-center/打开安全中心.png',"打开安全中心")
    commonly.test('Pictures/ukui-control-center/打开安全中心主页面.png',"安全中心主页面",click=False)
    pyautogui.hotkey("Alt","F4")
    commonly.test('Pictures/ukui-control-center/安全体检.png',"安全体检")
    commonly.test('Pictures/ukui-control-center/开始体检.png',"开始体检")
    commonly.test('Pictures/ukui-control-center/正在扫描中.png',"正在扫描中",click=False)
    pyautogui.hotkey("Alt","F4")
    commonly.test('Pictures/ukui-control-center/退出.png',"退出安全体检")
    commonly.test('Pictures/ukui-control-center/账户保护.png',"账户保护")
    commonly.test('Pictures/ukui-control-center/账户保护主页面.png',"账户保护主页面",click=False)
    pyautogui.hotkey("Alt","F4")
    commonly.test('Pictures/ukui-control-center/网络保护.png',"网络保护")
    commonly.test('Pictures/ukui-control-center/网络保护主页面.png',"网络保护主页面",click=False)
    pyautogui.hotkey("Alt","F4")
    commonly.test('Pictures/ukui-control-center/应用保护.png',"应用保护")
    commonly.test('Pictures/ukui-control-center/应用保护主页面.png',"应用保护主页面",click=False)
    pyautogui.hotkey("Alt","F4")
####################################################################################################################
#通知关于#
def about():
    commonly.test('Pictures/ukui-control-center/通知关于.png',"通知关于")
    commonly.test('Pictures/ukui-control-center/搜索.png',"搜索")
    commonly.test('Pictures/ukui-control-center/搜索主页面.png',"搜索主页面",click=False)
    commonly.test('Pictures/ukui-control-center/通知关于.png',"通知关于")
    commonly.test('Pictures/ukui-control-center/通知关于主界面.png',"通知关于主界面")

if __name__ == '__main__':
    system_main()
    cache()
    gexinghua()
    network()
    account()
    language()
    safe()
    about()
